<template>
  <div>
    <div class="title">
      <el-row>
        <el-col :span="1" style="width: 50px;">
          <span style="color:#757575;">位置 : </span>
        </el-col>
        <el-col :span="20">
          <span class="hand"></span>
        </el-col>
        <el-col :span="20">
          <span class="textactive">时间确认</span>
        </el-col>

      </el-row>
    </div>
    <div class="posttable">
      <div style="margin-bottom: 10px;background-color: #fff;" v-if="flag">
        <el-row type="flex" justify="center">
          <el-col :span="23" class="text">
            <el-col :span="12">
              <h4 style="width: 70px;display: inline-block;">今日上午</h4>
              <el-select class="interviewtrack" v-model.trim="customerName" placeholder="请选择推送客户"
                         @change="selectcustomer">
                <el-option
                  v-for="(item,index) in customerNames"
                  :key="index"
                  :label="item"
                  :value="item">
                </el-option>
              </el-select>
            </el-col>
            <el-col :span="12">
              <el-col style="width: 136px;float: right;">
                <el-button class="edit" size="small" v-if="jiaofu" @click="remindam" round>提醒
                </el-button>
                <el-button
                  class="send"
                  size="small"
                   v-if="jiaofu" 
                  round
                  @click="pushClick"
                >发送
                </el-button>
              </el-col>

            </el-col>
          </el-col>
        </el-row>
        <el-row type="flex" justify="center">
          <el-col :span="23">
            <el-table
              ref="singleTable"
              highlight-current-row
              :row-key="getRowKey"
              :data="tableData"
              @selection-change="handleSelectionChange"
              @current-change="handleCurrentChange"
            >
              <el-table-column
                :reserve-selection="true"
                type="selection"
                width="55"
              >
              </el-table-column>
              <el-table-column
                width="100"
                label="姓名"
              >
                <template slot-scope="scope">
                  <span style="color: #757575;">{{scope.row.name}}</span>
                </template>
              </el-table-column>
              <el-table-column
                width="100"
                prop="customerName"
                label="推送客户"
              >
              </el-table-column>
              <el-table-column
                width="100"
                prop="pusher"
                label="推送人"
              >
              </el-table-column>
              <el-table-column
                prop="postName"
                label="推送职位">
              </el-table-column>
              <el-table-column
                width="100"
                prop="postLevel"
                label="职位级别">
              </el-table-column>
              <el-table-column
                width="100"
                prop="type"
                label="面试次数">
              </el-table-column>
              <el-table-column
                width="150"
                prop="initialTime"
                label="候选人时间">
              </el-table-column>
              <el-table-column
                prop="communication"
                label="前期沟通情况"
              >
              </el-table-column>
              <el-table-column
                prop="candidateChangeReason"
                label="原因"
              >
              </el-table-column>
            </el-table>
            <div class="pager">
              <el-pagination
                @size-change="handleSizeChange"
                @current-change="pagehandleCurrentChange"
                :current-page="currentPage"
                :page-sizes="[5,10,15]"
                :page-size="pagesize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="totalcount"
              ></el-pagination>
            </div>
          </el-col>
        </el-row>
      </div>
      <div style="margin-bottom: 10px;background-color: #fff;">
        <el-row type="flex" justify="center">
          <el-col :span="23" class="text">
            <el-col :span="12">
              <h4 style="width: 70px;display: inline-block;">今日下午</h4>
              <el-select class="interviewtrack" v-model.trim="customerName1" placeholder="请选择推送客户"
                         @change="selectcustomer1">
                <el-option
                  v-for="(item,index) in customerNames1"
                  :key="index"
                  :label="item"
                  :value="item">
                </el-option>
              </el-select>
            </el-col>
            <el-col :span="12">
              <el-col style="width: 136px;float: right;">
                <el-button class="edit" size="small"  v-if="jiaofu"  @click="remindpm" round>提醒
                </el-button>
                <el-button
                  class="send"
                  size="small"
                   v-if="jiaofu" 
                  round
                  @click="pushClick1"
                >发送
                </el-button>
              </el-col>

            </el-col>
          </el-col>
        </el-row>
        <el-row type="flex" justify="center">
          <el-col :span="23">
            <el-table
              ref="singleTable1"
              highlight-current-row
              :data="tableData1"
              @current-change="handleCurrentChange1"
              :row-key="getRowKey1"
              @selection-change="handleSelectionChange1"
            >
              <el-table-column
                :reserve-selection="true"
                type="selection"
                width="55"
              >
              </el-table-column>
              <el-table-column
                width="100"
                label="姓名"
              >
                <template slot-scope="scope">
                  <span style="color: #757575;">{{scope.row.name}}</span>
                </template>
              </el-table-column>
              <el-table-column
                width="100"
                prop="customerName"
                label="推送客户"
              >
              </el-table-column>
              <el-table-column
                width="100"
                prop="pusher"
                label="推送人"
              >
              </el-table-column>
              <el-table-column
                prop="postName"
                label="推送职位">
              </el-table-column>
              <el-table-column
                width="100"
                prop="postLevel"
                label="职位级别">
              </el-table-column>
              <el-table-column
                width="100"
                prop="type"
                label="面试次数">
              </el-table-column>
              <el-table-column
                width="150"
                prop="initialTime"
                label="候选人时间">
              </el-table-column>
              <el-table-column
                prop="communication"
                label="前期沟通情况"
              >
              </el-table-column>
              <el-table-column
                prop="candidateChangeReason"
                label="原因"
              >
              </el-table-column>
            </el-table>
            <div class="pager">
              <el-pagination
                @size-change="handleSizeChange1"
                @current-change="pagehandleCurrentChange1"
                :current-page="currentPage1"
                :page-sizes="[5,10,15]"
                :page-size="pagesize1"
                layout="total, sizes, prev, pager, next, jumper"
                :total="totalcount1"
              ></el-pagination>
            </div>
          </el-col>
        </el-row>
      </div>
      <div style="margin-bottom: 10px;background-color: #fff;" v-if="flag1">
        <el-row type="flex" justify="center">
          <el-col :span="23" class="text">
            <el-col :span="12">
              <h4 style="width: 70px;display: inline-block;">明日上午</h4>
              <el-select class="interviewtrack" v-model.trim="customerName2" placeholder="请选择推送客户"
                         @change="selectcustomer2">
                <el-option
                  v-for="(item,index) in customerNames2"
                  :key="index"
                  :label="item"
                  :value="item">
                </el-option>
              </el-select>
            </el-col>
            <el-col :span="12">
              <el-col style="width: 136px;float: right;">
                <el-button class="edit" size="small"  v-if="jiaofu"  @click="remindtm" round>提醒
                </el-button>
                <el-button
                  class="send"
                  size="small"
                   v-if="jiaofu" 
                  round
                  @click="pushClick2"
                >发送
                </el-button>
              </el-col>

            </el-col>
          </el-col>
        </el-row>
        <el-row type="flex" justify="center">
          <el-col :span="23">
            <el-table
              ref="singleTable2"
              highlight-current-row
              :data="tableData2"
              @current-change="handleCurrentChange2"
              :row-key="getRowKey2"
              @selection-change="handleSelectionChange2"
            >
              <el-table-column
                :reserve-selection="true"
                type="selection"
                width="55">
              </el-table-column>
              <el-table-column
                width="100"
                label="姓名"
              >
                <template slot-scope="scope">
                  <span style="color: #757575;">{{scope.row.name}}</span>
                </template>
              </el-table-column>
              <el-table-column
                width="100"
                prop="customerName"
                label="推送客户"
              >
              </el-table-column>
              <el-table-column
                width="100"
                prop="pusher"
                label="推送人"
              >
              </el-table-column>
              <el-table-column
                prop="postName"
                label="推送职位">
              </el-table-column>
              <el-table-column
                width="100"
                prop="postLevel"
                label="职位级别">
              </el-table-column>
              <el-table-column
                width="100"
                prop="type"
                label="面试次数">
              </el-table-column>
              <el-table-column
                width="150"
                prop="initialTime"
                label="候选人时间">
              </el-table-column>
              <el-table-column
                prop="communication"
                label="前期沟通情况"
              >
              </el-table-column>
              <el-table-column
                prop="candidateChangeReason"
                label="原因"
              >
              </el-table-column>
            </el-table>
            <div class="pager">
              <el-pagination
                @size-change="handleSizeChange2"
                @current-change="pagehandleCurrentChange2"
                :current-page="currentPage2"
                :page-sizes="[5,10,15]"
                :page-size="pagesize2"
                layout="total, sizes, prev, pager, next, jumper"
                :total="totalcount2"
              ></el-pagination>
            </div>
          </el-col>
        </el-row>
      </div>

    </div>

    <el-dialog
      title="错误"
      :visible.sync="errordialogVisible"
      width="30%"
      :before-close="handleClose"
      class="deletedialog"
    >
      <div style="text-align: center">
        <i class="el-icon-warning" style="font-size: 20px;color: #fcb543;"><span
          style="font-size: 16px;color: #333;margin-left: 12px;">尚未选择任何候选人!</span></i>
      </div>
      <span slot="footer" class="dialog-footer">
           <el-button class="sure" round @click="handleClose">确 定</el-button>
    <el-button round @click="handleClose" class="cancel">取 消</el-button>
  </span>
    </el-dialog>

    <el-dialog
      title="错误"
      :visible.sync="errordialogVisible1"
      width="415px"
      :before-close="errorClose"
      class="addroledialog"
    >
      <div style="text-align: center">
        <i class="el-icon-warning" style="font-size: 20px;color: #fcb543;"><span
          style="font-size: 16px;color: #333;margin-left: 12px;">当前面试轮数不一致!</span></i>
      </div>
      <span slot="footer" class="dialog-footer">
           <el-button class="sure" round @click="errorClose">确 定</el-button>
    <el-button round @click="errorClose" class="cancel">取 消</el-button>
  </span>
    </el-dialog>

    <el-dialog
      title="错误"
      :visible.sync="errordialogVisible2"
      width="415px"
      :before-close="errorClose1"
      class="addroledialog"
    >
      <div style="text-align: center">
        <i class="el-icon-warning" style="font-size: 20px;color: #fcb543;"><span
          style="font-size: 16px;color: #333;margin-left: 12px;">统一接口人邮箱不一致!</span></i>
      </div>
      <span slot="footer" class="dialog-footer">
           <el-button class="sure" round @click="errorClose1">确 定</el-button>
    <el-button round @click="errorClose1" class="cancel">取 消</el-button>
  </span>
    </el-dialog>


    <el-dialog :visible.sync="dialogFormVisible" :before-close="cancelSend" class="back1">
      <div class="dialogBox">
        <el-row>
          <el-col :span="2" style="line-height:28px;color:#0e6195">收件人：</el-col>
          <el-col :span="10" class="receive">
            <span>{{mail}}</span>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="23">
            <div class="line"></div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="2" style="line-height:28px;color:#0e6195">
            抄送人：
          </el-col>
          <el-col :span="18" style="line-height:28px;font-size:12px;"><span v-for="(item,index) in copymail"
                                                                            :key="index">{{item}} <span>,</span></span>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="23">
            <div class="darkline"></div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="2" style="line-height:28px;color:#999798">主&nbsp;&nbsp;&nbsp;&nbsp;题：</el-col>
          <el-col :span="10" style="line-height:28px;font-size:12px;font-weight:700;">
            <el-select v-if="remark" size="mini" filterable v-model="theme" placeholder="请选择主题" @change="themeChange"
                       v-loading="loading">
              <el-option v-for="(item,index) in themeList" :key="index" :label="item" :value="item"></el-option>
            </el-select>
            <el-select v-if="!remark" size="mini" filterable v-model="sendTheme" placeholder="请选择主题"
                       @change="sendThemeChange" v-loading="sendLoading">
              <el-option v-for="(item,index) in sendThemeList" :key="index" :label="item" :value="item"></el-option>
            </el-select>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="23">
            <div class="lightLine"></div>
          </el-col>
        </el-row>
        <el-row style="border: 1px solid #ccc;">
          <el-col :span="12" style="padding-left: 10px;" class="mailtable mailtable1">
            <el-table
              v-if="times != '二面' && times != '三面' && !isGiveUp"
              class="tablelist"
              ref="mailtable"
              style="width:752px;"
              :data="maildata"
              border
            >
              <el-table-column
                width="92"
                prop="name"
                label="姓名"
              >
              </el-table-column>
              <el-table-column
                width="200"
                prop="postName"
                label="岗位"
              >
              </el-table-column>
              <el-table-column
                width="230"
                label="初次候选人面试时间"
              >
                <template slot-scope="scope">
                  <el-input v-model="scope.row.initialTime" disabled></el-input>
                </template>
              </el-table-column>
              <el-table-column
                width="230"
                :label="label"
              >
                <template slot-scope="scope">
                  <el-input v-model="scope.row.candidateTime" ></el-input>
                </template>
              </el-table-column>
            </el-table>
            <el-table
              v-if="times != '一面' && !isGiveUp"
              class="tablelist"
              ref="mailtable"
              style="width:938px;"
              :data="maildata"
              border
            >
              <el-table-column
                width="92"
                prop="name"
                label="姓名"
              >
              </el-table-column>
              <el-table-column
                width="200"
                prop="postName"
                label="岗位"
              >
              </el-table-column>
              <el-table-column
                width="230"
                :label="label"
              >
                <template slot-scope="scope">
                  <el-input v-model="scope.row.candidateTime"></el-input>
                </template>
              </el-table-column>
            </el-table>
            <el-table
              v-if="times != '二面' && times != '三面' && isGiveUp"
              class="tablelist"
              ref="mailtable"
              style="width:938px;"
              :data="maildata"
              border
            >
              <el-table-column
                width="92"
                prop="name"
                label="姓名"
              >
              </el-table-column>
              <el-table-column
                width="200"
                prop="postName"
                label="岗位"
              >
              </el-table-column>
              <el-table-column
                width="230"
                label="初次候选人面试时间"
              >
                <template slot-scope="scope">
                  <el-input v-model="scope.row.initialTime" disabled></el-input>
                </template>
              </el-table-column>
              <el-table-column
                width="230"
                :label="label"
              >
                <template slot-scope="scope">
                  <el-input v-model="scope.row.candidateTime" ></el-input>
                </template>
              </el-table-column>
              <el-table-column
                  width="200"
                  label="原因"
                >
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.candidateChangeReason" :disabled="!isGiveUp"></el-input>
                  </template>
                </el-table-column>
            </el-table>
            <el-table
              v-if="times != '一面' && isGiveUp"
              class="tablelist"
              ref="mailtable"
              style="width:722px;"
              :data="maildata"
              border
            >
              <el-table-column
                width="92"
                prop="name"
                label="姓名"
              >
              </el-table-column>
              <el-table-column
                width="200"
                prop="postName"
                label="岗位"
              >
              </el-table-column>
              <el-table-column
                width="230"
                :label="label"
              >
                <template slot-scope="scope">
                  <el-input v-model="scope.row.candidateTime"></el-input>
                </template>
                <el-table-column
                  width="200"
                  label="原因"
                >
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.candidateChangeReason" :disabled="!isGiveUp"></el-input>
                  </template>
                </el-table-column>
              </el-table-column>
            </el-table>
          </el-col>
          <el-col style="text-indent: 1.5em;margin-top: 30px;margin-left: 10px;margin-bottom: 30px;">
            <p>周颖</p>
            <p>软件研发中心 人力资源部</p>
            <p><span>公司 : </span> <span>北京神州新桥科技有限公司</span></p>
            <p><span>地址 : </span><span>北京市海淀区长春桥路11号万柳亿城大厦2号楼16层</span></p>
            <p><span>邮箱 : </span><span>sinorjyfzx@sino-bridge.com</span></p>
            <p><span>电话 : </span><span>(+86)15962999175</span></p>
          </el-col>

          <el-col style="margin-bottom: 18px;">
            <el-row type="flex" justify="center">
              <el-col :span="23">
                <div class="lightLine"></div>
              </el-col>
            </el-row>

          </el-col>

          <el-col>
          </el-col>
          <el-col>
            <div v-html="texthtml"></div>
          </el-col>
        </el-row>
      </div>
      <div slot="title" class="dialog-title">
        <el-button type="primary" size="small" :disabled="!sendEmailKey" @click="sendClick" style="font-size:16px;">
          <i class="iconfont icon-plane"></i>
          <span style="margin-left:6px;"> 发送</span>
        </el-button>
        <el-button @click="cancelSend">取 消</el-button>
        <el-input v-model="days" style="width:270px" placeholder="请输入需要寻找的天数内的发件箱主题"></el-input>

        <el-button type="primary" @click="getSendSub1">寻找收件箱</el-button>
        <el-button type="warning" @click="getSendSub">寻找发件箱</el-button>
        <el-button type="warning" @click="getallSendSub">寻找所有发件箱</el-button>

      </div>
    </el-dialog>


  </div>
</template>

<script>
  import axios from 'axios'
  import tagsView from '../../store/modules/tagsView'
  export default {
    name: "dove",
    data() {
      return {
        uploadlist: [],
        tableData: [],
        currentPage: 1,
        pagesize: 5,
        totalcount: 0,
        currentRow: null,
        tableData1: [],
        currentPage1: 1,
        pagesize1: 5,
        totalcount1: 0,
        jiaofu:true,
        currentRow1: null,
        tableData2: [],
        currentPage2: 1,
        pagesize2:5,
        totalcount2: 0,
        currentRow2: null,
        errordialogVisible: false,
        multipleSelection: [],
        multipleSelection1: [],
        multipleSelection2: [],
        dialogFormVisible: false,
        copier: "",
        theme: '',
        maildata: [],
        themelist: [],
        loading: false,
        customerName: '',
        customerNames: [],
        customerName1: '',
        customerNames1: [],
        customerName2: '',
        customerNames2: [],
        mail: '',
        times: "一面",
        sendTheme: "",
        loading: true,
        label: "修改后候选人面试时间",
        sendLoading: true,
        sendEmailKey: true,
        days: '',
        texthtml: '',
        remark: true,
        copymail: [],
        themeList: [],
        sendThemeList: [],
        flag: false,
        flag1: false,
        editdialogVisible: false,
        errordialogVisible1: false,
        errordialogVisible2: false,
        type : null,
        isGiveUp:false
      }
    },
    created() {
      if(tagsView.state.identity == 7){
        this.jiaofu = false;
      }
      axios.post(this.url + '/todayinterview/selectcustomernames1').then(res => {
        this.unlogin(res.data.code)
        if (res.data.code == 200) {
          this.customerNames = res.data.data;
        }
      });
      axios.post(this.url + '/todayinterview/selectcustomernames2').then(res => {
        this.unlogin(res.data.code)
        if (res.data.code == 200) {
          this.customerNames1 = res.data.data;
        }
      });
      axios.post(this.url + '/todayinterview/selectcustomernames3').then(res => {
        this.unlogin(res.data.code)
        if (res.data.code == 200) {
          this.customerNames2 = res.data.data;
        }
      });
      this.selectinterviewforhr1();
      this.selectinterviewforhr2();
      this.selectinterviewforhr3();
    },
    methods: {
      //今日上午
      selectinterviewforhr1() {
        axios.post(this.url + '/todayinterview/selectinterviewforassistant1', {
          pageNum: this.currentPage,
          pageSize: this.pagesize,
          customerName: this.customerName
        }).then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            if (res.data.data !== null) {
              this.flag = true;
              this.tableData = res.data.data.list;
              this.totalcount = res.data.data.total;
            } else {
              this.flag = false;
            }
          }
        })
      },
      //今日下午
      selectinterviewforhr2() {
        axios.post(this.url + '/todayinterview/selectinterviewforassistant2', {
          pageNum: this.currentPage1,
          pageSize: this.pagesize1,
          customerName: this.customerName1
        }).then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.tableData1 = res.data.data.list;
            this.totalcount1 = res.data.data.total;
          }
        })
      },
      //明天上午
      selectinterviewforhr3() {
        axios.post(this.url + '/todayinterview/selectinterviewforassistant3', {
          pageNum: this.currentPage2,
          pageSize: this.pagesize2,
          customerName: this.customerName2
        }).then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            if (res.data.data !== null) {
              this.flag1 = true;
              this.tableData2 = res.data.data.list;
              this.totalcount2 = res.data.data.total;
            }
          } else {
            this.flag1 = false;
          }
        })
      },
      selectcustomer() {
        this.currentPage = 1;
        this.selectinterviewforhr1();
        this.multipleSelection = [];
        this.$refs.singleTable.clearSelection();
      },
      selectcustomer1() {
        this.currentPage1 = 1;
        this.selectinterviewforhr2();
        this.multipleSelection1 = [];
        this.$refs.singleTable1.clearSelection();
      },
      selectcustomer2() {
        this.currentPage2 = 1;
        this.selectinterviewforhr3();
        this.multipleSelection2 = [];
        this.$refs.singleTable2.clearSelection();
      },
      getRowKey(row) {
        return row.id
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      getRowKey1(row) {
        return row.id
      },
      handleSelectionChange1(val) {
        this.multipleSelection1 = val;
      },
      getRowKey2(row) {
        return row.id
      },
      handleSelectionChange2(val) {
        this.multipleSelection2 = val;
      },
      remindam() {
        let ids = [];
        if (this.multipleSelection.length == 0) {
          ids = []
        } else {
          for (let i = 0, len = this.multipleSelection.length; i < len; i++) {
            ids.push(this.multipleSelection[i].id)
          }
        }
        axios.post(this.url + '/todayinterview/remind', {
          ids: ids
        }).then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.multipleSelection = [];
            this.$refs.singleTable.clearSelection();
          }
        })
      },
      remindpm() {
        let ids = [];
        if (this.multipleSelection1.length == 0) {
          ids = []
        } else {
          for (let i = 0, len = this.multipleSelection1.length; i < len; i++) {
            ids.push(this.multipleSelection1[i].id)
          }
        }
        axios.post(this.url + '/todayinterview/remind', {
          ids: ids
        }).then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.multipleSelection1 = [];
            this.$refs.singleTable1.clearSelection();
          }
        })
      },
      remindtm() {
        let ids = [];
        if (this.multipleSelection2.length == 0) {
          ids = []
        } else {
          for (let i = 0, len = this.multipleSelection2.length; i < len; i++) {
            ids.push(this.multipleSelection2[i].id)
          }
        }
        axios.post(this.url + '/todayinterview/remind', {
          ids: ids
        }).then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.multipleSelection2 = [];
            this.$refs.singleTable2.clearSelection();
          }
        })
      },
      pushClick() {
        if (this.multipleSelection.length == 0) {
          this.errordialogVisible = true;
          document.documentElement.style.overflow = 'hidden';
        } else {
          this.type = 1;
          let requireNums = [];
          let arr = [];
          for (let i = 0, len = this.multipleSelection.length; i < len; i++) {
            requireNums.push(this.multipleSelection[i].type);
            arr.push(this.multipleSelection[i].no);
            if (this.multipleSelection[i].candidateTime == "放弃面试" || this.multipleSelection[i].candidateTime == "面试待定") {
                  this.isGiveUp = true
                }
          }
          this.times= this.multipleSelection[0].type;
          this.maildata = JSON.parse(JSON.stringify(this.multipleSelection));
          axios.post(this.url + '/resumeUpload/isSameRequireNum', {
            requireNums: requireNums
          }).then(res => {
            this.unlogin(res.data.code);
            if (res.data.code == 200) {
              if (res.data.message == "fail") {
                document.documentElement.style.overflow = 'hidden';
                this.errordialogVisible1 = true;
              } else if (res.data.message == "success") {
                axios.post(this.url + '/mailreplay/getmail', {
                  arr: arr
                }).then(res => {
                  this.unlogin(res.data.code);
                  if (res.data.code == 200) {
                    if (res.data.message == "success") {
                      this.mail = res.data.data.mail;
                      this.copymail = res.data.data.cc;
                      document.documentElement.style.overflow = 'hidden';
                      this.dialogFormVisible = true;
                      axios.post(this.url + "/mailreplay/getsub", {
                        mail: this.mail,
                        day: this.days
                      }).then(res => {
                        this.unlogin(res.data.code);
                        if (res.data.code == 200) {
                          this.themeList = res.data.data
                          this.loading = false
                        }
                      })
                    } else {
                      document.documentElement.style.overflow = 'hidden';
                      this.errordialogVisible2 = true;
                    }
                  }
                })
              }
            }
          })
        }
      },
      pushClick1() {
        if (this.multipleSelection1.length == 0) {
          this.errordialogVisible = true;
          document.documentElement.style.overflow = 'hidden';
        } else {
          let requireNums = [];
          let arr = [];
          this.type = 2;
          for (let i = 0, len = this.multipleSelection1.length; i < len; i++) {
            requireNums.push(this.multipleSelection1[i].type);
            arr.push(this.multipleSelection1[i].no);
            if (this.multipleSelection1[i].candidateTime == "放弃面试" || this.multipleSelection1[i].candidateTime == "面试待定") {
                  this.isGiveUp = true
                }
          }
          this.times= this.multipleSelection1[0].type;
          this.maildata = JSON.parse(JSON.stringify(this.multipleSelection1));
          axios.post(this.url + '/resumeUpload/isSameRequireNum', {
            requireNums: requireNums
          }).then(res => {
            this.unlogin(res.data.code);
            if (res.data.code == 200) {
              if (res.data.message == "fail") {
                document.documentElement.style.overflow = 'hidden';
                this.errordialogVisible1 = true;
              } else if (res.data.message == "success") {
                axios.post(this.url + '/mailreplay/getmail', {
                  arr: arr
                }).then(res => {
                  this.unlogin(res.data.code);
                  if (res.data.code == 200) {
                    if (res.data.message == "success") {
                      this.mail = res.data.data.mail;
                      this.copymail = res.data.data.cc;
                      document.documentElement.style.overflow = 'hidden';
                      this.dialogFormVisible = true;
                      axios.post(this.url + "/mailreplay/getsub", {
                        mail: this.mail,
                        day: this.days
                      }).then(res => {
                        this.unlogin(res.data.code);
                        if (res.data.code == 200) {
                          this.themeList = res.data.data
                          this.loading = false
                        }
                      })
                    } else {
                      document.documentElement.style.overflow = 'hidden';
                      this.errordialogVisible2 = true;
                    }
                  }
                })
              }
            }
          })


        }
      },
      pushClick2() {
        if (this.multipleSelection2.length == 0) {
          this.errordialogVisible = true;
          document.documentElement.style.overflow = 'hidden';
        } else {
          let requireNums = [];
          let arr = [];
          this.type = 2;
          for (let i = 0, len = this.multipleSelection2.length; i < len; i++) {
            requireNums.push(this.multipleSelection2[i].type);
            arr.push(this.multipleSelection2[i].no);
            if (this.multipleSelection2[i].candidateTime == "放弃面试" || this.multipleSelection2[i].candidateTime == "面试待定") {
                  this.isGiveUp = true
                }
          }
          this.times= this.multipleSelection2[0].type;
          this.maildata = JSON.parse(JSON.stringify(this.multipleSelection2));
          axios.post(this.url + '/resumeUpload/isSameRequireNum', {
            requireNums: requireNums
          }).then(res => {
            this.unlogin(res.data.code);
            if (res.data.code == 200) {
              if (res.data.message == "fail") {
                document.documentElement.style.overflow = 'hidden';
                this.errordialogVisible1 = true;
              } else if (res.data.message == "success") {
                axios.post(this.url + '/mailreplay/getmail', {
                  arr: arr
                }).then(res => {
                  this.unlogin(res.data.code);
                  if (res.data.code == 200) {
                    if (res.data.message == "success") {
                      this.mail = res.data.data.mail;
                      this.copymail = res.data.data.cc;
                      document.documentElement.style.overflow = 'hidden';
                      this.dialogFormVisible = true;
                      axios.post(this.url + "/mailreplay/getsub", {
                        mail: this.mail,
                        day: this.days
                      }).then(res => {
                        this.unlogin(res.data.code);
                        if (res.data.code == 200) {
                          this.themeList = res.data.data
                          this.loading = false
                        }
                      })
                    } else {
                      document.documentElement.style.overflow = 'hidden';
                      this.errordialogVisible2 = true;
                    }
                  }
                })
              }
            }
          })
        }
      },
      handleClose(done) {
        this.errordialogVisible = false;
        document.documentElement.style.overflow = 'auto';
      },
      //上午
      handleSizeChange(val) {
        this.pagesize = val;
        this.selectinterviewforhr1();
      },
      handleCurrentChange(val) {
        this.currentRow = val;
      },
      pagehandleCurrentChange(val) {
        this.currentPage = val;
        this.selectinterviewforhr1();
      },
      //下午
      handleSizeChange1(val) {
        this.pagesize1 = val;
        this.selectinterviewforhr2();
      },
      handleCurrentChange1(val) {
        this.currentRow1 = val;
      },
      pagehandleCurrentChange1(val) {
        this.currentPage1 = val;
        this.selectinterviewforhr2();
      },
      //明天上午
      handleSizeChange2(val) {
        this.pagesize2 = val;
        this.selectinterviewforhr3();
      },
      handleCurrentChange2(val) {
        this.currentRow2 = val;
      },
      pagehandleCurrentChange2(val) {
        this.currentPage2 = val;
        this.selectinterviewforhr3();
      },
      submitForm(formName) {

      },
      errorClose() {
        document.documentElement.style.overflow = 'auto';
        this.errordialogVisible1 = false;
      },
      errorClose1() {
        document.documentElement.style.overflow = 'auto';
        this.errordialogVisible2 = false;
      },
      // 发送邮件
      sendClick() {
        let data = [];
        if (this.isGiveUp) {
          for (let i = 0; i < this.maildata.length; i++) {
            data.push({
              name: this.maildata[i].name,
              postname: this.maildata[i].postName,
              interviewTimeok: this.maildata[i].candidateTime,
              reason: this.maildata[i].candidateChangeReason,
              initialTime: this.maildata[i].initialTime
            })
          }
        } else {
          for (let i = 0; i < this.maildata.length; i++) {
            data.push({
              name: this.maildata[i].name,
              postname: this.maildata[i].postName,
              interviewTimeok: this.maildata[i].candidateTime,
              initialTime: this.maildata[i].initialTime
            })
          }
        }

        let id = [];
          if(this.type == 1){
            for (let i = 0, leng = this.multipleSelection.length; i < leng; i++) {
              id.push(this.multipleSelection[i].id)
            }
          }
          if(this.type == 2){
            for (let i = 0, leng = this.multipleSelection1.length; i < leng; i++) {
              id.push(this.multipleSelection1[i].id)
            }
          }
          if(this.type == 13){
            for (let i = 0, leng = this.multipleSelection2.length; i < leng; i++) {
              id.push(this.multipleSelection2[i].id)
            }
          }

        if (this.sendEmailKey) {
          this.sendEmailKey = false;
          let customer = '';
          if(this.type == 1){
            customer = this.multipleSelection[0].customerName;
          }
          if(this.type == 2){
            customer = this.multipleSelection1[0].customerName;
          }
          if(this.type == 3){
            customer = this.multipleSelection2[0].customerName;
          }

          axios.post(this.url + '/telesolicit/send', {
            id: id,
            to: this.mail,
            cc: this.copymail,
            sub: this.theme,
            content: this.texthtml,
            arr: data,
            customer: customer
          }).then(res => {
            this.unlogin(res.data.code);
            if (res.data.code == 200) {
              this.dialogFormVisible = false;
              document.documentElement.style.overflow = 'auto';
              if(this.type == 1){
                this.$refs.singleTable.clearSelection();
                this.selectinterviewforhr1();
              }
              if(this.type == 2){
                this.$refs.singleTable1.clearSelection();
                this.selectinterviewforhr2();
              }
              if(this.type == 3){
                this.$refs.singleTable1.clearSelection();
                this.selectinterviewforhr2();
              }

              this.texthtml = "";
              this.theme = "";
              this.remark = true;
              this.loading = true;
              this.sendLoading = true;
              this.sendTheme = "";
              this.sendEmailKey = true;
            }
          })
        }

      },
      cancelSend() {
        this.dialogFormVisible = false;
        this.loading = true;
        this.isGiveUp = false;
        this.sendLoading = true;
        this.sendEmailKey = true;
        this.texthtml = "";
        this.theme = "";
        this.remark = true;
        document.documentElement.style.overflow = "auto";
        if(this.type == 1){
          this.$refs.singleTable.clearSelection();
          this.selectinterviewforhr1();
          this.type = null;
        }
        if(this.type == 2){
          this.$refs.singleTable1.clearSelection();
          this.selectinterviewforhr2();
          this.type = null;
        }
        if(this.type == 3){
          this.$refs.singleTable1.clearSelection();
          this.selectinterviewforhr2();
          this.type = null;
        }

      },
      getMailData() {

      },
      themeChange(val) {
        axios.post(this.url + "/mailreplay/getcontent", {
          sub: val
        }).then(res => {
          this.unlogin(res.data.code)
          if (res.data.code == 200) {
            this.texthtml = res.data.data
          }
        })
      },
      sendThemeChange(val) {
        this.theme = val
        axios.post(this.url + "/mailreplay/getSentcontent", {
          sub: val
        }).then(res => {
          this.unlogin(res.data.code)
          if (res.data.code == 200) {
            this.texthtml = res.data.data
          }
        })
      },
      getSendSub1() {
        this.remark = true;
        this.loading = true;
        this.disabled = true;
        axios.post(this.url + '/mailreplay/getsub', {
          mail: this.mail,
          day: this.days
        }).then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.themeList = res.data.data;
            this.loading = false;
            this.disabled = false;
          }
        })
      },
      getSendSub() {
        this.remark = false;
        this.sendLoading = true;
        axios.post(this.url + "/mailreplay/getSentsub", {
          mail: this.mail,
          day: this.days
        }).then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.sendThemeList = res.data.data;
            this.sendLoading = false;
          }
        })
      },
      getallSendSub() {
        this.remark = false;
        this.sendLoading = true;
        axios.post(this.url + "/mailreplay/getAllSentsub", {
          mail: this.mail,
          day: this.days
        }).then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.sendThemeList = res.data.data;
            this.sendLoading = false;
          }
        })
      },
    },
  }
</script>

<style scoped>
  .title {
    background-color: #fff;
    height: 40px;
    line-height: 40px;
    font-size: 14px;
    padding-left: 20px;
    margin-top: 6px;
    margin-bottom: 6px;
  }

  .posttable {
    min-height: 700px;
    background-color: #f4f7f9;
  }

  .textactive {
    color: #1099ff;
  }


  .edit {
    width: 65px;
    height: 28px;
    padding: 7px 15px !important;
    opacity: 0.86;
    color: #fff;
    background: linear-gradient(to bottom, #00cebf 0%, #009085 100%);
  }

  .text {
    height: 50px;
    line-height: 50px;
  }

  .send {
    width: 65px;
    height: 28px;
    opacity: 0.86;
    color: #fff;
    background: linear-gradient(to bottom, #feaa12 0%, #f28316 100%);
    padding: 7px 15px !important;
  }

  .line {
    height: 1px;
    background-color: #c8c8c8;
    margin-top: 3px;
    margin-bottom: 20px;
  }

  .darkline {
    height: 1px;
    background-color: #4288c3;
    margin-bottom: 20px;
  }

  .mailtable1 {
    width: 100% !important;
  }

  .lightLine {
    height: 1px;
    background-color: #cccccc;
    margin-top: 10px;
    margin-bottom: 10px;
  }

  .pager {
    width: 100%;
    overflow: hidden;
    position: relative;
    margin-top: 10px;
    margin-bottom: 10px;
  }

  .el-pagination {
    margin-left: 50%;
    transform: translateX(-50%);
  }
</style>
